﻿using System.Windows;
using BlueMarble.Genesis.Infrastructure;
using Microsoft.Practices.Composite.Modularity;
using Microsoft.Practices.Composite.Regions;
using Microsoft.Practices.Unity;

namespace BlueMarble.Genesis.View
{
    public class ViewModule : IModule
    {
        private readonly IUnityContainer container;
        private readonly IRegionManager regionManager;

        public ViewModule(IUnityContainer container, IRegionManager regionManager)
        {
            this.container = container;
            this.regionManager = regionManager;
        }

        #region IModule Members

        public void Initialize()
        {
            RegisterViewsAndServices();

            this.regionManager.RegisterViewWithRegion(BlueMarble.Genesis.Infrastructure.Resources.RegionNames.MainRegion,
                () => this.container.Resolve<IMainViewModel>().View);
        }

        protected void RegisterViewsAndServices()
        {
            this.container.RegisterType<IMainView, MainView>();
            this.container.RegisterType<IMainViewModel, MainViewModel>();
        }

        #endregion

    }
}
